//
//  LSBookListCell.m
//  LibraryStorm
//
//  Created by Enel@Lightning on 3/26/14.
//  Copyright (c) 2014 3ATeam. All rights reserved.
//

#import "LSBookListCell.h"
#import "UIImageView+AFNetworking.h"
#import "LSDownloadManager.h"
#import "LSCustomCellBackground.h"

@implementation LSBookListCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/
- (void)awakeFromNib
{
    LSCustomCellBackground *backgroundView = [[LSCustomCellBackground alloc] initWithFrame:CGRectZero];
    self.selectedBackgroundView = backgroundView;
    self.nameLabel.font = Roboto_Bold((IS_DEVICE_IPAD ? 22 : 15));
    self.authorLabel.font = Roboto_Regular((IS_DEVICE_IPAD ? 20 : 14));
    self.nameLabel.textColor = [UIColor blackColor];
    self.nameLabel.highlightedTextColor = [UIColor whiteColor];
    self.authorLabel.textColor = [UIColor blackColor];
    self.authorLabel.highlightedTextColor = [UIColor whiteColor];
}

- (void)loadContentCell:(BookDetail *)book atIndexPath:(NSIndexPath *)indexPath
{
    if (book) {
        [self.coverImageView setImageWithURL:[NSURL URLWithString:book.coverImage] placeholderImage:BOOK_COVER_IMAGE];
        self.nameLabel.text = book.name;
        self.authorLabel.text = book.author;
        self.downloadIconImageView.hidden = YES;
        self.progressView.hidden = YES;
        if (book.downloadStatus.intValue == LSObjectDownloadCompleted && book.bookPath.length > 0) {
            self.downloadIconImageView.hidden = NO;
        }
    }
}
@end
